import urllib, urllib2  
import base64, re  
  
url = 'https://mirrorgm.cloudapp.net/crypto200_a88aaf1d235bb917f97e3e5b988bea60/index.php'
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'  
  
def get_ciper():  
	headers = { 'User-Agent' : user_agent}  
	data = ''
	request = urllib2.Request(url, data, headers)  
	response = urllib2.urlopen(request)  
	cookie = response.info().get('Set-Cookie')
	#print cookie
	ciper = cookie[cookie.find('cipher=') + len('cipher='):]
	print ciper + "\n"
	ciper = base64.b64decode(ciper)
	print len(ciper)
	return ciper
  
def set_cookie(cookie):  
	#cookie = base64.b64encode(cookie)
	#print cookie
	cookie = urllib.quote(cookie)  
	headers = { 'User-Agent' : user_agent, 'Cookie': cookie}  
	request = urllib2.Request(url, None, headers)  
	response = urllib2.urlopen(request)  
	data = response.read()  
	print data
	#ck = response.info().get('Set-Cookie')

def alter_cookie(cookie):
	return base64.b64encode(cookie[:6] + chr(ord(cookie[6]) ^ 0x10) + cookie[6:])

def create_posible(cookie):
	i = 2
	while i < 48:
		ck = base64.b64encode(cookie[:i] + chr(ord(cookie[i]) ^ 0x10) + cookie[i:])
		print ck + "\n"
		set_cookie(ck)
		i = i+ 1

ck = get_ciper()
ck = create_posible(ck)
